package com.easymin.weixin.manager.impl;

import com.easymin.weixin.common.api.SimpleCarPoolApi;
import com.easymin.weixin.controller.v4.ResultTransport;
import com.easymin.weixin.manager.SimpleCarPoolManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class DefaultSimpleCarPoolManager implements SimpleCarPoolManager {
  @Autowired
  SimpleCarPoolApi simpleCarPoolApi;

  /**
   * 查询服务人员附近线路.
   */
  @Override
  public Map<String, Object> roadLines(Double lat, Double lng, String appKey) {

    return simpleCarPoolApi.roadLines(lng, lat, appKey);
  }

  /**
   * 查询指定线路.
   */
  @Override
  public Map<String, Object> roadLine(Long roadLineId, String appKey) {

    return simpleCarPoolApi.roadLine(roadLineId, appKey);
  }

  /**
   * 查询单个工作车.
   */
  @Override
  public Map<String, Object> car(Long carId, String appKey) {

    return simpleCarPoolApi.car(carId, appKey);
  }

  @Override
  public Map<String, Object> book(Long roadLineId, Double bookLat, Double bookLng, Long bookTime,
      String bookArea, Long employId, String employName, String employPhone, String appKey) {
    employPhone = employPhone.replaceAll(" ", "");
    employPhone = employPhone.replaceAll("-", "");
    return simpleCarPoolApi.book(roadLineId, bookLat, bookLng, bookTime, bookArea, employId,
        employName, employPhone, appKey);
  }

  /**
   * 取消工作车订单.
   */
  @Override
  public Map<String, Object> cancel(Long bookId, String appKey) {
    return simpleCarPoolApi.cancel(bookId, appKey);
  }

  /**
   * 查询工作车订单.
   */
  @Override
  public Map<String, Object> books(Long employId, String appKey) {
    return simpleCarPoolApi.books(employId, appKey);
  }

  @Override
  public ResultTransport bookV4(Long roadLineId, Double bookLat, Double bookLng, Long bookTime,
      String bookArea, Long employId, String employName, String employPhone, String appKey) {
    return simpleCarPoolApi.bookV4(roadLineId, bookLat, bookLng, bookTime, bookArea, employId,
        employName, employPhone, appKey);
  }

  @Override
  public ResultTransport roadLinesV4(Double lat, Double lng, String appKey) {
    return simpleCarPoolApi.roadLinesV4(lat, lng, appKey);
  }

  @Override
  public ResultTransport roadLineV4(Long roadLineId, String appKey) {
    return simpleCarPoolApi.roadLineV4(roadLineId, appKey);
  }

  @Override
  public ResultTransport carV4(Long carId, String appKey) {
    return simpleCarPoolApi.carV4(carId, appKey);
  }

  @Override
  public ResultTransport booksV4(Long employId, String appKey) {
    return simpleCarPoolApi.booksV4(employId, appKey);
  }

  @Override
  public ResultTransport cancelV4(Long bookId, String appKey) {
    return simpleCarPoolApi.cancelV4(bookId, appKey);
  }

}
